package com.example.zhaojianxu.signin.common.account.viewModel

import android.util.Log
import android.widget.Toast
import com.example.zhaojianxu.signin.common.account.model.AccountEntity
import com.example.zhaojianxu.signin.common.account.model.UserEntity
import com.example.zhaojianxu.signin.common.constance.ComConstance
import com.example.zhaojianxu.signin.common.http.HttpUtil
import com.example.zhaojianxu.signin.common.util.ToastUtil
import com.google.gson.Gson
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.async
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
import java.lang.Exception

object AccountRequest {

    fun postLogin(account: String, password: String) = GlobalScope.async {
        var json: UserEntity? = null

        try {
            json = HttpUtil.instance.getCommonApi()?.postLogin(account, password)?.execute()?.body()
            json
        } catch (e: Exception) {
            e.printStackTrace()
            json
        }
    }

    fun postLogon(account: String, password: String, name: String, number: String) = GlobalScope.async {
        var json: String? = null
        try {
            json = HttpUtil.instance.getCommonApi()?.postLogon(account,password,name,number,"1")?.execute()?.body()
            json
        } catch (e: Exception) {
            json
        }
    }
}